package com.example.activity01;

import com.example.activity01.R.string;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

	private EditText et1;
	private EditText et2;
	private TextView tv1; 
	private Button btn1; 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		TextView tv1 = (TextView)findViewById(R.id.tv1);
		Button btn1 = (Button)findViewById(R.id.btn1);
		tv1.setText(R.string.tv1);
		btn1.setText(R.string.btn1);
		btn1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				EditText et1 = (EditText)findViewById(R.id.et1);
				EditText et2 = (EditText)findViewById(R.id.et2);
				String str1 = et1.getText().toString();
				String str2 = et2.getText().toString();
				Intent intent = new Intent();
				intent.putExtra("value1", str1);
				intent.putExtra("value2", str2); 
				intent.setClass(MainActivity.this, result.class);
				startActivity(intent);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		menu.add(0, 1, 1, R.string.exit);
		menu.add(0, 2, 2, R.string.about);
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		if(item.getItemId()==1)
			finish();
		return super.onOptionsItemSelected(item);
	}

}
